********Clean and compile data needed for analysis from IFLS4 and IFLS5********

*Clean IFLS4 data
cd "$reploc/programs"
do clean_ifls4.do
tempfile ifls4full
save "`ifls4full'", replace

*Clean IFLS5 data
cd "$reploc/programs"
do clean_ifls5.do
tempfile ifls5full
save "`ifls5full'", replace

*Append IFLS4 and IFLS5 data
use "`ifls4full'", clear
append using "`ifls5full'"

tempfile ifls45full
save "`ifls45full'"

*Create timelines to get precise location, migration, and birth information
cd "$reploc/programs"
do timelines.do
cd "$reploc/data/created_data"
save indiv_prov_hist, replace


*Create lifetime experienced real GDP growth mean and real GDP growth standard deviation
cd "$reploc/programs"
do growth_stats.do
cd "$reploc/data/created_data"
save indiv_provgrbir_stats, replace

*Create lifetime experienced real GDP growth mean and real GDP growth standard deviation, for state of residence
cd "$reploc/programs"
do growth_stats_stateresidence.do
cd "$reploc/data/created_data"
save indiv_provgrres_stats, replace


*Merge lifetime macro experiences and clean IFLS data for analysis
cd "$reploc/programs"
do vars_ifls.do "`ifls45full'"
cd "$reploc/data/created_data"
save indo_full, replace




